package com.wang.servlet;

import com.wang.pojo.Person;
import sun.security.jca.ServiceId;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

public class Session02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //解决编码
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");


        //得到session
        HttpSession session = req.getSession();
        Person person = (Person) session.getAttribute("name");        //给Session设置一些值

        System.out.println(person.toString());


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
